import 'package:flutter/material.dart';

class ThemeProvider with ChangeNotifier {
  ThemeProvider();

  static final _themes = <ThemeData>[
    ThemeData(colorSchemeSeed: Colors.red),
    ThemeData(colorSchemeSeed: Colors.orange),
    ThemeData(colorSchemeSeed: Colors.yellow),
    ThemeData(colorSchemeSeed: Colors.green),
    ThemeData(colorSchemeSeed: Colors.blue),
    ThemeData(colorSchemeSeed: Colors.indigo),
    ThemeData(colorSchemeSeed: Colors.purple),
  ];
  ThemeData themeData = _themes[0];
  int _index = 0;

  String getThemeName() {
    switch (_index) {
      case 0:
        return 'Red${_colorToHex(Colors.red)}';
      case 1:
        return 'Orange${_colorToHex(Colors.orange)}';
      case 2:
        return 'Yellow${_colorToHex(Colors.yellow)}';
      case 3:
        return 'Green${_colorToHex(Colors.green)}';
      case 4:
        return 'Blue${_colorToHex(Colors.blue)}';
      case 5:
        return 'Indigo${_colorToHex(Colors.indigo)}';
      case 6:
        return 'Purple${_colorToHex(Colors.purple)}';
      default:
        return 'Unknown';
    }
  }

  String _colorToHex(Color color, {bool leadingHashSign = true}) {
    return '${leadingHashSign ? '#' : ''}${color.toARGB32().toRadixString(16)}';
  }

  void changeTheme() {
    _index = (_index + 1) % _themes.length;
    themeData = _themes[_index];
    notifyListeners();
  }
}
